#if !defined(__HTTP_RESPONSE_H)
#    define __HTTP_RESPONSE_H

#    include <httpBasic.h>
#    include <httpCode.h>
#    include <iostream>
#    include <map>

namespace http {
    class httpResponse {
    protected:
        static StringMap                  fileTypeMap;
        static std::map<int, std::string> codeMap;

    public:
        static void InitFileTypesMap(std::string filepath);

    protected:
        std::string version;
        std::string code;
        StringMap   heard;
        std::string body;
        std::string fileType;
        std::string charset;

        std::string text;

    public:
        const std::string &getCode() const {
            return code;
        }
        void setCode(std::string code) {
            this->code.assign(code);
        }
        httpResponse(std::string version = "HTTP/1.1", std::string code = Http_200);
        ~httpResponse();

        void         setBody(const char *buff, size_t buff_size);
        void         setFileType(std::string fileName);

        void heardAdd(const std::string &key, const std::string& value);
        void setCookie(const std::string &cookie);

        std::string &operator[](std::string key);
        std::string &toText();

    protected:
        void analyseType(std::string type);
    };

}  // namespace http

#endif  // __HTTP_RESPONSE_H
